package com.example.demo.mapper;

import com.example.demo.entity.Teacher;
import org.apache.ibatis.annotations.*;
import org.springframework.security.core.parameters.P;

import java.util.List;

@Mapper
public interface TeacherMapper {

    @Select("select * from tuser")
    List<Teacher> findAllTea();

    @Select("select * from tuser where tid=#{tid}")
    Teacher findTeaByTid(int tid);

    @Select("select * from tuser where tname=#{tname}")
    Teacher findTeaByName(String tname);

    @Select("select * from tuser where college=#{college}")
    List<Teacher> findTeaByCollege(String college);

    @Select("select * from tuser where college=#{college} and grade=#{grade}")
    Teacher findTeaByCollegeAndGrade(@Param("college") String college, @Param("grade") String grade);

    @Delete("delete from tuser where tid=#{tid}")
    int deleteByTid(int tid);

    @Insert("insert into tuser(tid,tname,sex,college,grade,tel) values(#{tid},#{tname},#{sex},#{college},#{grade},#{tel})")
    int addTea(Teacher teacher);

    @Update("update tuser set tname=#{tname},sex=#{sex},college=#{college},grade=#{grade},tel=#{tel} where tid=#{tid}")
    int updateTea(@Param("tname") String tname, @Param("sex") int sex, @Param("college") String college, @Param("grade") String grade, @Param("tel") String tel, @Param("tid") int tid);
}
